package com.example.bomc.dao;


import com.example.bomc.model.FixStaff;
import com.example.bomc.model.Trouble;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface FixDao {

    String TABLE_NAME = "publicTrouble";
    String INSET_FIELDS = " trouble, reply, fixwork";
    String SELECT_FIELDS = " password";

    /**
     * 登录
     */
    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME, " where fixname=#{fixname}"})
    FixStaff selectByFixName(String name);

    /**
     * 解决问题
     */
    @Update({"update",TABLE_NAME,"set tag =#{tag} where id=#{id} "})
    void fixTrouble(@Param("tag") String  tag, @Param("id") int id);

    /**
     * 查询所有共性问题
     */
    @Select({"select ", INSET_FIELDS, " from ", TABLE_NAME})
    List<FixStaff> selAllTrouble();

    /**
     * 查询共性问题
     */
    @Select({"select ", INSET_FIELDS, " from ", TABLE_NAME, " where trouble=#{trouble} "})
    List<FixStaff> selTroubleByTrouble(@Param("trouble") String trouble);

    /**
     * 新增共性问题
     */
    @Insert({"insert into ", TABLE_NAME, "(", INSET_FIELDS,
            ") values (#{trouble},#{reply},#{fixwork})"})
    void addSameTrouble(Trouble trouble);
    /**
     * 修改共性问题
     */
    @Update({"update",TABLE_NAME,"set reply =#{reply} where id=#{id} "})
    void updateTrouble(@Param("reply") String  reply, @Param("id") int id);
    /**
     * 删除共性问题
     */
    @Delete({"delete from",TABLE_NAME,"where trouble=#{trouble}"})
    void deleteStaff(@Param("trouble") String fixname);
}
